/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.innovision.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {
	
    private static final String FORMAT_DATE = "yyyy-MM-dd";
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat(FORMAT_DATE);


	private Utils() {
	}

	   public static String date2string(Date date) {
		if (date == null) {
			return null;
		}
		return dateFormat.format(date);
	}

	public static Date string2date(String date) {
		if (date == null) {
			return null;
		}
		Date dt = null;

		try {
			dt = dateFormat.parse(date);
		} catch (ParseException excpt) {
			return null;
		}
		return dt;
	}
        public static java.sql.Date string2SQLdate(String date) {
		if (date == null) {
			return null;
		}
		java.sql.Date dt = null;

		try {
			dt = new java.sql.Date(dateFormat.parse(date).getTime());
		} catch (ParseException excpt) {
			return null;
		}
		return dt;
	}
}
